
// 弹幕组件需要的参数类 包含弹幕内容、位置、颜色、大小、是否显示（默认显示）
class Danmu {
    constructor(content, location, color,  size = 14, speed = 5,  show = true) {
        this.content = content
        this.location = location
        this.color = color
        this.speed = speed
        this.size = size
        this.show = show
    }
}

export default {
    data: {
        dataArr: [],
        inputText: "",
        colorArr: ['black', 'blue', 'green', 'red', 'orange', 'yellow'],
        sizeArr: [
            {
                size: 12,
                title: '小'
            },
            {
                size: 14,
                title: '中'
            },
            {
                size: 18,
                title: '大'
            },
            {
                size: 30,
                title: '超大'
            },
        ],
        currentColorIndex: 0,
        currentSizeIndex: 1
    },
    onInit() {
    },
    onDestroy() {
    },
    // 获取弹幕输入内容
    change(e) {
        this.inputText = e.value
    },
    // 发送弹幕
    sendDanmu() {
        let dmTemp = new Danmu(this.inputText, Math.ceil(Math.random() * 50), this.colorArr[this.currentColorIndex], this.sizeArr[this.currentSizeIndex].size)
        this.dataArr.push(dmTemp)
        this.inputText = ""
    },
    // 选择弹幕颜色
    selectColor(index) {
        this.currentColorIndex = index;
    },
    // 选择弹幕字体大小
    selectSize(index) {
        this.currentSizeIndex = index;
    }
}
